<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\admin\model;
use think\Model;
use think\Cache;

/**
 * Description of Classify
 *
 * @author HuangLuSen
 */
class Classify extends Model {
    //put your code here
    public function getStatusTextAttr($value,$data)
    {
        $status = [1=>'<span class="label label-success">正常</span>',0=>'<span class="label label-danger">禁用</span>'];
        return $status[$data['status']];
    }

    /**
     * 获取所有的类别
     * @return array|mixed
     * @author: Huang
     */
    public function getAllClassify(){
        $data = Cache::tag('Classify')->get('Classifydata');
        if(!$data){
            $data=$this->column('title','id');
            Cache::tag('Classify')->set('Classifydata',$data);
        }
        return $data;
    }
}
